
$(function(){
	layui.use(['table','layer'], function(){
	  	var table = layui.table;
		  
	  	table.on('edit(test3)', function(obj){
    		var value = obj.value //得到修改后的值
    		,data = obj.data //得到所在行所有键值
    		,field = obj.field; //得到字段
    		layer.msg('[ID: '+ data.id +'] ' + field + ' 字段更改为：'+ value);
  		});
  		
	  	table.render({
	    	elem: '#userTable',
	    	id: 'userReloadTable',		//重载时需要
	    	url:  'json/user.json',
	    	height: 315,
	    	page: true,
	    	cols: [[
	    		{checkbox: true, fixed: true},
	      		{field:'userid', width:80, title: '账号', sort: true},
	      		{field:'username', width:80, title: '姓名'},
	      		{field:'sex', width:80, title: '性别'},
	      		{field:'age', width:80, title: '年龄'},
	      		{field:'role', title: '角色'},
	      		{field:'status', width:100, title: '状态'}
	    	]]
	  	});
	  	

	});
	
	//新增用户按钮
	$("#addBtn").on('click',function(){
		$.ajax({
			type:"get",
			url:"html/user_add.html",
			success: function(html){
  				layer.open({
  					id:'adduserlayer',
  					title:'新增用户',
    				type: 1,
    				area:'500px',
    				content: html ,
    				success: function(layero, index){
    					$("#submitBtn").on('click',function(){
									
						});
	
						$("#closeBtn").on('click',function(){
							layer.close(index);
						});
    				}
  				});
			}
		});
	});
	
	//批量删除按钮
	$("#batDelBtn").on('click',function(){
		
	});
	
});